<template>
  <div :class="$style.header">
    <div :class="$style.leftbtn" @click="back">
      <i class="iconfont icon-fanhui"></i>
    </div>
    <div :class="$style.leftbtn" style="visibility: hidden">
      <i class="iconfont icon-fanhui"></i>
    </div>
    <div :class="$style.title">{{ title }}</div>
    <div :class="$style.rightbtn" @click="checkRefresh"
      :style="{ visibility: showRefresh ? 'visible' : 'hidden' }">
      <i class="iconfont icon-shuaxin"></i>
    </div>
    <div :class="$style.rightbtn" @click="share"
      :style="{ visibility: hasShare ? 'visible' : 'hidden' }">
      <i class="iconfont icon-fenxiang"></i>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      title: {
        type: String,
        default: ''
      },
      hasShare: {
        type: Boolean,
        default: false
      },
      showRefresh: {
        type: Boolean,
        default: false
      }
    },

    methods: {
      back () {
        if (typeof (this.$route.query.cleanStorage) !== 'undefined') {
          window.location.href = "gtjanormal://goback"
        } else {
          this.$router.go(-1)
        }
      },
      share () {
        this.$emit('onShare')
      },
      checkRefresh () {
        this.$emit('refresh')
      }
    }
  }
</script>

<style lang="less" module>
  .header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px;
    background-color: #E54F20;
    display: flex;
    z-index: 9999;
  }

  .leftbtn, .rightbtn {
    width: 50px;
  }

  .leftbtn {
    line-height: 32px;
    font-size: 20px;
    width: 36px;
    height: 36px;
    text-align: center;
    border-radius: 999px;
    margin-top: 4px;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    border: 1px solid #FFF;

    i {
      font-size: 22px;
      line-height: 36px;
    }
  }

  .rightbtn {
    line-height: 32px;
    font-size: 20px;
    width: 36px;
    height: 36px;
    text-align: center;
    border-radius: 999px;
    margin-top: 4px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    border: 1px solid #FFF;

    i {
      font-size: 22px;
      line-height: 36px;
    }
  }

  .title {
    flex: 1;
    text-align: center;
    color: #FFF;
    font-size: 17px;
    height: 44px;
    line-height: 44px;
  }
</style>